/*
 * @Author: 一路向阳 tt_sunzhenfeng@163.com
 * @Date: 2024-02-21 18:34:47
 * @LastEditors: 一路向阳 tt_sunzhenfeng@163.com
 * @LastEditTime: 2024-02-21 18:45:33
 * @FilePath: \utils_ts\16.枚举.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
export {};

// 枚举不是用来定义类型， 列举数据用的

// enum Xxx {
//   a = 10,
//   b = '200'
// }

enum StatusCode {
  success = 200,
  paramsError = 400,
  serverError = 500
}

let code: string | number = 400;

if(code === StatusCode.success) {
  console.log('成功');
}
else if(code === StatusCode.paramsError) {
  console.log('失败，请求参数问题');
}
else if(code === StatusCode.serverError) {
  console.log('失败，服务器问题');
}

enum StatusCode2 {
  success, // 0
  paramsError = 400, // 400
  serverError // 401
}

console.log(StatusCode2.success, StatusCode2.paramsError, StatusCode2.serverError);
